<template>
	<view>
		<view class="box">
			<view class="info" @click="toCourseDetails(item)">
				<image :src="orderinfo.img.split(',')[0]" class="info_left"></image>
				<view class="info_right">
					<view class="title_box">
						<view class="title">{{orderinfo.activity_name}}</view>
						<!-- <view class="status">{{pay_status[orderinfo.verifiy_status]}}</view> -->
					</view>
					<view class="time_box">
						<!-- <view class="tag">报名截止时间</view> -->
						<view class="time">活动时间：{{dateFormat(orderinfo.create_time)}}</view>
						<!-- <view class="class_hour">共{{item.class_num}}课节</view> -->
					</view>
					<view class="time_box">
						<!-- <view class="tag">报名截止时间</view> -->
						<!-- <view class="time">活动地址：滨江1号 14栋 2单元 302</view> -->
						<!-- <view class="class_hour">共{{item.class_num}}课节</view> -->
					</view>
					<view class="teacher" style="color: #222;">
						<view>￥{{orderinfo.sign_money}}</view>
					</view>
				</view>

			</view>
			<view class="btns">
				<!-- <view class="btn_box">
					<view class="btn1" @click="toApplyRefund">申请取消</view>
					<view class="btn2" :style="{'opacity':orderinfo.is_can_hx==0?0.5:''}" @click="openHxm(item)">核销二维码</view>
				</view> -->
				<view class="btn3" @click="toscan">核销二维码</view>
			</view>
		</view>
		<!-- <view class="infobox">
			<view class="title">报名信息</view>
			<view class="infotit">
				<view class="name">订单号</view>
				<view>500017086791<text style="color: #FE768A;">复制</text></view>
			</view>
			<view class="infotit">
				<view class="name">活动人数</view>
				<view>30人</view>
			</view>
			<view class="infotit">
				<view class="name">课本费</view>
				<view>3688积分+￥10</view>
			</view>
			<view class="infotit">
				<view class="name">支付方式</view>
				<view>在线支付</view>
			</view>
			<view class="infotit">
				<view class="name">报名时间</view>
				<view>2023.06.16  14:00</view>
			</view>
		</view> -->
		<view class="listbox">
			<view class="title">
				报名人员
				<view @click="more()">
					<view>全部</view>
					<image src="../../static/xia.png"></image>
				</view>
			</view>
			<view class="listitem" v-for="(item,index) in orderinfo.list" :key="index"
				v-if="index<=openindex?true:false">
				<view class="infosbox">
					<view class="leftbox">
						<view class="name">{{item.username}}</view>
						<view>{{ dateFormat(item.pay_time) }}</view>
					</view>
					<view class="rightbox">
						<!-- /verifiy_status核销状态0未核销1已核销 -->
						<!-- 从支付状态0未支付 1已支付，3已取消/退款 -->
						<view style="color: #FF6178;" v-if="item.verifiy_status==0">未核销</view>
						<view v-if="item.verifiy_status==1">已核销</view>
					</view>
				</view>
				<!-- <view class="btns" >
					<view class="btn_box">
						<view class="btn1" @click="toApplyRefund">申请取消</view>
						<view class="btn2" :style="{'opacity':orderinfo.is_can_hx==0?0.5:''}" @click="openHxm(item)">核销二维码</view>
					</view>
					<view class="btn3"  @click="openHxm">申请取消</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import jweixin from '../../utils/wxSdk.js'
	export default {
		data() {
			return {
				orderinfo: {},
				openindex: 5,
				addressinfo: {},
				id:'',
			}
		},
		onLoad(option) {
			this.getinfo(option.id)
			this.id = option.id
		},
		methods: {
			getinfo(id) {
				this.$http({
					url: '/api/api/adminActivityDetail',
					data: {
						activity_id: id
					}
				}).then(res => {
					this.orderinfo = res.data
				})
			},
			more() {
				if (this.openindex == 9999) { //
					this.openindex = 5
				} else {
					this.openindex = 9999
				}
				if (this.orderinfo.list.length <= 5) {
					uni.showToast({
						title: '已展示全部',
						icon: 'none'
					})
				}
			},
			dateFormat: function(value) {
				var date = new Date(value * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var year = date.getFullYear();
				var month = ("0" + (date.getMonth() + 1)).slice(-2);
				var sdate = ("0" + date.getDate()).slice(-2);
				var hour = ("0" + date.getHours()).slice(-2);
				var minute = ("0" + date.getMinutes()).slice(-2);
				var second = ("0" + date.getSeconds()).slice(-2);
				// 拼接
				var result = year + "年" + month + "月" + sdate + "日 " + hour + ":" + minute //+ ":" + second;
				// 返回
				return result;
			},
			// 扫码核销
			async toscan() {
				this.addressinfo = await this.$wxSdk.wxScanQRCode()
				this.binduser()
				console.log(this.addressinfo, 'addressinfo')
				// 只允许通过相机扫码
				// let that = this
				// uni.scanCode({
				// 	onlyFromCamera: true,
				// 	success: function(res) {
				// 		console.log('条码类型：' + res.scanType);
				// 		console.log('条码内容：' + res.result);
				// 		that.$http({
				// 			url: '/api/api/activityScanCode',
				// 			data: {
				// 				code_data: res.result
				// 			}
				// 		}).then(res => {
				// 			uni.showToast({
				// 				title:res.msg,
				// 				icon:'none',
				// 				duration:3000
				// 			})
				// 			this.getinfo()
				// 		})
				// 	}
				// });
			},
			binduser() {
				this.$http({
					url: '/api/api/activityScanCode',
					data: {
						code_data: this.addressinfo.resultStr
					}
				}).then(res => {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 3000
					})
					this.getinfo(this.id)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		padding: 36rpx 30rpx 0 30rpx;
		box-sizing: border-box;
		margin-bottom: 24rpx;

		.info {
			display: flex;
			justify-content: space-between;
			gap: 0 26rpx;
			padding-bottom: 30rpx;

			.info_left {
				width: 160rpx;
				height: 160rpx;
				background: #FFFFFF;
				border-radius: 6rpx;
				flex-shrink: 0;
			}

			.info_right {
				width: 100%;
				display: flex;
				flex-direction: column;

				.title_box {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 30rpx;

					.title {
						font-size: 36rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #222222;
						line-height: 1em;
					}

					.status {
						font-size: 28rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #FF8A9B;
					}
				}

				.time_box {
					display: flex;
					align-items: center;
					margin-bottom: 20rpx;
					// justify-content: space-between;

					.tag {
						padding: 6rpx 6rpx 4rpx 6rpx;
						background: linear-gradient(180deg, #FCBB8C 0%, #FF8158 100%);
						font-size: 28rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #FFFFFF;
						line-height: 1em;
						border-radius: 4rpx 8rpx 8rpx 8rpx;
						margin-right: 18rpx;
					}

					.time {
						font-size: 28rpx;
						font-family: Source Han Sans CN-Regular, Source Han Sans CN;
						font-weight: 400;
						color: #555555;
						line-height: 1em;
						// margin-right: 20rpx;
					}

					.class_hour {
						font-size: 28rpx;
						font-family: Source Han Sans CN-Regular, Source Han Sans CN;
						font-weight: 400;
						color: #555555;
						line-height: 1em;
					}
				}

				.teacher,
				.student {
					font-size: 28rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #555555;
					line-height: 1em;
					display: flex;
					align-items: center;

					.studentitem {
						display: flex;
						width: 400rpx;

						>view {
							-webkit-line-clamp: 1;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							overflow: hidden;
							text-overflow: ellipsis;
						}
					}

					>view {
						-webkit-line-clamp: 1;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}

				.teacher {
					margin-bottom: 20rpx;
				}
			}
		}

		.btns {
			width: 690rpx;
			height: 108rpx;
			border-top: 2rpx solid #ECECEC;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.btn_box {
				width: 100%;
				height: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
			}

			.btn1 {
				width: 320rpx;
				height: 68rpx;
				border-radius: 36rpx;
				border: 2rpx solid #888888;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #222222;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.btn2 {
				width: 320rpx;
				height: 68rpx;
				background: #FF8A9B;
				border-radius: 36rpx;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #FFFFFF;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.btn3 {
				width: 690rpx;
				height: 68rpx;
				border-radius: 36rpx;
				background: #FF8A9B;
				// border: 2rpx solid #888888;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #FFF;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}

	}

	.infobox {
		width: 690rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		opacity: 1;
		padding: 0 30rpx;

		.title {
			height: 120rpx;
			line-height: 120rpx;
			font-size: 40rpx;
			font-family: SourceHanSansCN-Medium-, SourceHanSansCN-Medium;
			font-weight: normal;
			color: #FF6178;
		}

		.infotit {
			height: 100rpx;
			display: flex;
			font-size: 32rpx;
			font-family: Source Han Sans CN-Medium, Source Han Sans CN;
			font-weight: 500;
			color: #222222;
			justify-content: space-between;

			.name {
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #666666;
			}

		}
	}

	.listbox {
		width: 690rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		opacity: 1;
		padding: 0 30rpx;

		.title {
			height: 120rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 40rpx;
			font-family: SourceHanSansCN-Medium-, SourceHanSansCN-Medium;
			font-weight: normal;
			color: #FF6178;

			>view {
				display: flex;
				align-items: center;
				font-size: 30rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #222222;

				image {
					width: 18rpx;
					height: 14rpx;
					margin-left: 14rpx;
				}
			}
		}

		.listitem {
			// height: 158rpx;
			padding: 20rpx 0;
			border-bottom: dashed 2rpx #ECECEC;

			.infosbox {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.leftbox {
					width: 550rpx;
					font-size: 26rpx;
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					font-weight: 400;
					color: #555555;

					.name {
						// width:320rpx;
						font-size: 28rpx;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #222222;
						-webkit-line-clamp: 1;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						overflow: hidden;
						text-overflow: ellipsis;
						margin-bottom: 20rpx;
					}
				}

				.rightbox {
					font-size: 28rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #222222;
				}
			}

			.code {
				width: 600rpx;
				margin: 0 auto;
				text-align: center;

				image {
					width: 500rpx;
					height: 500rpx;
				}
			}

			.btns {
				width: 690rpx;
				height: 108rpx;
				border-top: 2rpx solid #ECECEC;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.btn_box {
					width: 100%;
					height: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;
				}

				.btn1 {
					width: 320rpx;
					height: 68rpx;
					border-radius: 36rpx;
					border: 2rpx solid #888888;
					font-size: 32rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #222222;
					display: flex;
					justify-content: center;
					align-items: center;
				}

				.btn2 {
					width: 320rpx;
					height: 68rpx;
					background: #FF8A9B;
					border-radius: 36rpx;
					font-size: 32rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #FFFFFF;
					display: flex;
					justify-content: center;
					align-items: center;
				}

				.btn3 {
					width: 690rpx;
					height: 68rpx;
					border-radius: 36rpx;
					border: 2rpx solid #888888;
					font-size: 32rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #222222;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
		}
	}
</style>